package com.shengdong.water.code.adapter

import com.shengdong.water.R
import com.shengdong.water.code.base.BaseRecyclerAdapter
import com.shengdong.water.code.bean.SignInBean
import com.shengdong.water.databinding.ItemSignRecordBinding

class SignRecordAdapter : BaseRecyclerAdapter<SignInBean,ItemSignRecordBinding>() {
    override fun getLayoutId() = R.layout.item_sign_record


    override fun bindData(binding: ItemSignRecordBinding, item: SignInBean, position: Int) {
        binding.item = item

        // 可以在这里添加额外的绑定逻辑
//        binding.signTime.text = item.createTime
        binding.locationPoint.text = buildString {
        append(item.signLat)
        append(",")
        append(item.signLon)
    }

        binding.executePendingBindings()
    }

    // 如果User有唯一ID，可以重写这个方法提高效率
    override fun areItemsTheSame(oldItem: SignInBean, newItem: SignInBean): Boolean {
        return oldItem.id == newItem.id
    }

    // 内容比较可以更精确
    override fun areContentsTheSame(oldItem: SignInBean, newItem: SignInBean): Boolean {
        return oldItem.createUser == newItem.createUser && oldItem.dischargeOutletId == newItem.dischargeOutletId
    }

}